package plugins

import (
	"crypto/md5"
	"fmt"
)

type MD5Manager struct {
}

func (p *MD5Manager) TransformStringToMD5(content interface{}) string {
	if str, ok := content.(string); ok {
		data := []byte(str)
		hash := md5.Sum(data)
		md5Str := fmt.Sprintf("%x", hash)
		return md5Str
	} else {
		panic("content is expect string type")
	}
}

func (p *MD5Manager) VerifyIsEquality(content interface{}, md5 string) bool {
	return p.TransformStringToMD5(content) == md5
}
